package com.wgy.day40SQL.多表查询;

/**
 * Created by pc on 2020/12/21 22:03
 * Description: LearningJava
 */
/*
多表查询的概述:

准备sql:
# 创建部门表
CREATE TABLE dept(
id INT PRIMARY KEY AUTO_INCREMENT,
NAME VARCHAR(20)
);

#创建员工表
CREATE TABLE emp(
id INT  PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(20),
gender CHAR(1),
salary DOUBLE,
join_date DATE,
dept_id INT,
FOREIGN KEY (dept_id) REFERENCES dept (id)
 );

 #给员工表添加数据
 INSERT INTO emp (NAME,gender,salary,join_date,dept_id) VALUES ('孙悟空','男',7200,'2013-02-23',1) ;
 INSERT INTO emp (NAME,gender,salary,join_date,dept_id) VALUES ('猪八戒','男',3600,'2010-12-23',2) ;
 INSERT INTO emp (NAME,gender,salary,join_date,dept_id) VALUES ('唐僧','男',9000,'2008-08-08',2) ;
 INSERT INTO emp (NAME,gender,salary,join_date,dept_id) VALUES ('白骨精','女',5000,'2015-10-07',3) ;
 INSERT INTO emp (NAME,gender,salary,join_date,dept_id) VALUES ('蜘蛛精','女',3000,'2011-03-14',1) ;

笛卡尔积:
 有两个集合A,B 取这两个集合的所有组成情况
 要完成多表查询,需要消除无用的数据

多表查询的分类:
1.内连接查询
2.外连接查询
3.子查询

 SELECT *FROM emp, dept WHERE emp.`dept_id`=dept.`id`;

 SELECT
       t1.`name`,
       t1.`gender`,
       t2.name
  FROM emp t1,
       dept t2
  WHERE
       t1.`dept_id`=t2.`id`;
 */
public class Demo08 {
}
